'use strict';
// 植入别名
const path = require('path');
const cwd = process.cwd();
const buildConf = require('../entry/entryConf.js');
// 工作空间根目录
let prodBuildPath;

// build 文件夹目录
prodBuildPath = path.join(cwd, `./build`);

// todo // 每个工作空间应该有独自的别名文件
let alias = {resolve: {alias: {}}};
try {
  alias = require(`../bizConfs/${buildConf.curEntry}/alias.json`);
} catch (e) {
  console.log(e)
}

// build 文件夹下的webpack 基础配置文件
const baseWebpackConfig = require(path.join(prodBuildPath, `./webpack.base.conf.js`));
// 先看基础配置中的别名是否存在, 不存在就用 alias 的
baseWebpackConfig.resolve ? Object.keys(alias.resolve.alias).forEach(item => {
  baseWebpackConfig.resolve.alias[item] = alias.resolve.alias[item];
}) : (baseWebpackConfig.resolve = alias.resolve);
// 然后再开启 dev 开发环境
console.log(baseWebpackConfig.resolve);

module.exports = require(path.join(prodBuildPath, './webpack.dev.conf.js'));
